<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>推送提醒</title>
    <include file="Public:easyui_res" />
</head>
<body>
<div id="tb" style="padding:5px;height:auto;">
    <div style="margin: 10px 0 10px 10px" >
        <!-- form表单 指定id和name之后会自动带到服务器 -->
        <form name="searchform" method="get" action="" id ="searchform" style="height:20px;margin-bottom: 20px">

            <label for="push_state">推送状态：</label>
            <select class="easyui-combobox" id ="push_state" name="push_state" style="width:140px;height:32px;">
                <option value="">不限</option>
                <option value="2">推送中</option>
                <option value="3">已推送</option>
                <option value="1">未推送</option>
                <option value="4,5">不推送</option>
            </select>

            <label for="activity_state">活动状态：</label>
            <select class="easyui-combobox" id ="activity_state" name="activity_state" style="width:140px;height:32px;">
                <option value="0">不限</option>
                <option value="1">未开始</option>
                <option value="2">进行中</option>
                <option value="3">已结束</option>
            </select>

            <label for="activity_title">关键字：</label>
            <input class="easyui-textbox" id="activity_title" name="activity_title" data-options="prompt:'按标题查询'" style="width:140px;height:32px"/>

            <label for="order_by">排序方式：</label>
            <select class="easyui-combobox" id ="order_by" name="order_by" style="width:140px;height:32px;">
                <option value="1" selected="selected">按上线时间</option>
                <option value="2">按点击量</option>
            </select>

            <a href="javascript:void(0);" id="submit_search" class="easyui-linkbutton" iconCls="icon-search"  style="width:60px;height:32px">查询</a>
            <a href="__URL__/activityEdit" class="easyui-linkbutton" iconCls="icon-add"  style="height:32px;float: right;margin-right: 60px">添加</a>
        </form>
    </div>
</div>
<table id="dg"  style="width:100%; min-height: 500px"  title="查询结果"
       data-options="rownumbers:false,
			singleSelect:true,
			pagination:true,
			ctrlSelect:true,
			fitColumns:true,
			loadMsg:'正在加载,请等待....',
			url:'__URL__/getActivityList',
			method:'post',
			toolbar:'#tb',
			">
    <thead>
    <tr>
        <volist name="table_title" id="vo"  >
            <th data-options="field:'{$key}',align:'center',width:'10px'">{$vo}</th>
        </volist>
    </tr>
    </thead>
</table>
<script type="text/javascript">
    var height = document.documentElement.clientHeight;
    height = height - 20;
    $("#dg").css("height",height+"px");
    function view_pic(url){
        var data = "<img src='"+url+"' id='pic' height='300px' />";
        $.messager.alert('查看图片',"",'info');
        $(".messager-window").css("width","");
        $(".messager-body").css("width","");
        $(".window-header").css("width","");
        $(".messager-window").css("left","100px");
        $(".messager-window").css("top","40px");
        $(".window-shadow").css("display","none");
        $(".messager-body").html(data);
    }
    function goSend(id,type){
        $.messager.confirm('提示', '确定要发布吗?', function(r){
            if(r){
                $.ajax( {
                    url: '__URL__/activityPub',
                    type: 'post',
                    data: {'id':id,'push_state':type},
                    cache:false,
                    dataType:'json',
                    success: function (data){
                        if(data >0 ){ //影响行大于0则成功
                            m_info("发布成功");
                            $('#dg').datagrid({ queryParams: form2Json("searchform") });
                        }else{
                            m_erro("发布失败");
                        }
                    },
                    error: function (data, status, e){
                        m_erro("发布失败");
                        $('#dg').datagrid({ queryParams: form2Json("searchform") });
                        //m_erro(e);
                    }
                });
            }
        });
    }
    function goPush(id,type){
        $.messager.confirm('提示', '确定要推送吗?', function(r){
            if(r){
                $.ajax( {
                    url: '__URL__/activityPush',
                    type: 'post',
                    data: {'id':id,'client_type':type},
                    cache:false,
                    dataType:'json',
                    success: function (data){
                        if(data >0 ){ //影响行大于0则成功
                            m_info("推送成功");
                            $('#dg').datagrid({ queryParams: form2Json("searchform") });
                        }else{
                            m_erro("推送失败");
                        }
                    },
                    error: function (data, status, e){
                        m_erro("推送失败");
                        $('#dg').datagrid({ queryParams: form2Json("searchform") });
                        //m_erro(e);
                    }
                });
            }
        });
    }
    function activityDel(id){
        $.messager.confirm('提示', '确定要删除吗?', function(r){
            if(r){
                $.ajax( {
                    url: '__URL__/activityDel',
                    type: 'post',
                    data: {'id':id},
                    cache:false,
                    dataType:'json',
                    success: function (data){
                        if(data >0 ){ //影响行大于0则成功
                            m_info("删除成功");
                            $('#dg').datagrid({ queryParams: form2Json("searchform") });
                        }else{
                            m_erro("删除失败");
                        }
                    },
                    error: function (data, status, e){
                        m_erro("删除失败");
                        $('#dg').datagrid({ queryParams: form2Json("searchform") });
                        //m_erro(e);
                    }
                });
            }
        });
    }
</script>
</body>
</html>